import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/vue-element-admin/user/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/vue-element-admin/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout() {
  return request({
    url: '/vue-element-admin/user/logout',
    method: 'post'
  })
}


//从前API设计
// '/vue-element-admin/user/findAll',
// '/vue-element-admin/user/findById',
// '/vue-element-admin/user/save',
// '/vue-element-admin/user/update',
// '/vue-element-admin/user/delete',
// '/vue-element-admin/user/deletes',

//RESTful API 
// '/vue-element-admin/user'      GET    == findAll
// '/vue-element-admin/user/id'   GET    == findById
// '/vue-element-admin/user'      POST   == saveOrUpdate   表单是否提交id
// '/vue-element-admin/user/id'   DELET  == delete


//新增查询方法，返回用户列表集合
export function fetchList(query) {
  return request({
    url: '/vue-element-admin/user',
    method: 'get',
    params: query
  })
}

export function createUser(data) {
  return request({
    url: '/vue-element-admin/user',
    method: 'post',
    data //id==null
  })
}

export function updateUser(data) {
  return request({
    url: '/vue-element-admin/user',
    method: 'post',
    data  //id!=null
  })
}

export function deleteUsers(userIds) {
  return request({
    url: '/vue-element-admin/user/' + userIds,
    method: 'delete'
  })
}